$(document).ready(function() {
    var tblPage;
    if ($("#tablePagination").length > 0)
        tblPage = "tablePagination"
    else if ($("#tblSchedule").length > 0)
        tblPage = "tblSchedule";
    var rowCount = $('#' + tblPage + ' tbody tr').length;
    paginationSchedule(rowCount, tblPage);

    hljs.initHighlightingOnLoad();
    $('textarea#inputBody').ckeditor();

//datepicker
    if ($(".inputScheduleDateSubject").length > 0) {
        $(".inputScheduleDateSubject").datepicker({
            dateFormat: 'dd/mm/yy',
        });
    } else {
        $(".iptDate").datepicker({
            dateFormat: 'dd/mm/yy',
        });
    }



//popup create issue

    $(".popup-issue").fancybox({
        maxWidth: 800,
        maxHeight: 600,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none'
    });

    //live search usser
    if ($("#live-search-user").length > 0) {
        $("#live-search-user").keyup(function() {
            var value = this.value;
            $("table#tbView tr").each(function(index) {
                if (index === 0)
                    return;
                var id = $(this).find("td:nth-child(3)").text();
                $(this).toggle(id.indexOf(value) !== -1);
            })
        });
    }
    if ($("#inputScheduleDateSubject").length > 0 && $("#inputScheduleLession").length > 0) {
        $("#inputScheduleDateSubject").change(function() {
            $("#divScheduleSubject").fadeIn();
            $("#divScheduleLession").fadeIn();
            $("#divDayOff").fadeOut();
            $("#notificationText1").fadeOut();
            $("#notificationText1").empty();
            $("#getSubjectID").empty();

            var cl = $("#inputScheduleClass").val();
            var d_get = $('#inputScheduleDateSubject').val().replace(/\//g, "");
            $.ajax({
                type: 'GET',
                url: '../Schedule/checkExist/' + cl + "c" + d_get,
                success: function(data) {
                    if (data.length > 0) {
                        //alert($("#inputScheduleLession"));
                        //alert(data);

                        $("#notificationText1").fadeIn();
                        $("#notificationText1").append("Tiết học của lớp " + $("#inputScheduleClass").find("option:checked").text() + " vào ngày " + $('#inputScheduleDateSubject').val() + " đã tồn tại trong Database. Điền thông tin vào textbox bên dưới nếu là ngày nghỉ");
                        $("#divScheduleSubject").fadeOut();
                        $("#divScheduleLession").fadeOut();
//                        alert(data[0].subject_id);
                        $("#getSubjectID").val(data[0].subject_id);
                        $("#divDayOff").fadeIn();
                        $("#txtDayOff").focus();
                        $("input[name=chs][value=chsDayOff]").attr("checked", true);
                    }
                }
            });
        });
    }
//jquery cho Project/schedule/create
    if ($("#inputScheduleClass").length > 0) {
        $("#inputScheduleClass").change(function() {
            $("#inputScheduleDateSubject").focus();
            $("div #sltDay").empty();
            $("div #sltDay").append('<table class="table"> <tr><td><label> <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="2" id="chkMonday" disabled="on"/> Monday</label></td> <td><label> <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="3" id="chkTueday" disabled="on"/> Tuesday</label></td> <td><label> <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="4" id="chkWednesday" disabled="on"/> Wednesday</label></td> </tr> <tr> <td><label> <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="5" id="chkThursday" disabled="on" /> Thursday</label></td> <td><label> <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="6" id="chkFridays" disabled="on"/> Friday</label></td> <td><label> <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="7" id="chkSaturday" disabled="on"/> Saturday</label></td> </tr> </table>');
            $.ajax({
                type: 'GET',
                url: "../Class/getDayOfWeek/" + $(this).val(),
                dataType: 'json',
                contentType: 'application/json',
                success: function(data) {
                    if (data.length > 0) {
                        //Kiểm tra tồn tại csdl
                        $("input[name='sltDayOfWeek[]']").each(function() {
                            if ($.inArray($(this).val(), data) != -1) {
                                $(this).attr("checked", true);
                            }
                        });
                    }
                    else {
                        //nếu kiểm tra chưa cài đặt thứ cho lớp thì chuyển đi đến update của lớp đó
                        answer = confirm("Please update Date Of Week.\nChoose OK to redirect");
                        if (answer != 0)
                        {
                            var urlLocation = "../class/update/" + $("#inputScheduleClass").val();
                            location = urlLocation;
                        } else {
                            $("#inputScheduleClass").click();
                            return false;
                        }
                    }
                }
            });
            $.ajax({
                type: 'GET',
                url: "../Subject/getlist/" + $(this).val(),
                dataType: 'json',
                contentType: 'application/json',
                success: function(data) {
                    var slt = $("#inputScheduleSubject");
                    slt.empty();
                    if (data.length > 0) {
                        slt.append("<option value='-1'>Select Subject</option>");
                        //alert(data.length);

                        for (i = 0; i < data.length; i++) {
                            slt.append("<option value='" + data[i].subject_id + "'>" + data[i].subject_name + "</option>");
                        }
                    } else {
                        slt.append("<option>Empty</option>");
                    }

                }

            });

        });
    }

    $('#inputScheduleClassBySch').on('change', function() {
        //if ($(this).val() != '-1') {
        $('#btnGetListSchedule').click();

        //}
    });
//jquery choose day-off or add a lession to schedule
    if ($("input[name=chs]").length > 0) {
        $("input[name=chs]").change(function() {
            if ($(this).val() == "chsDayOff") {
                $("#divScheduleSubject").fadeOut();
                $("#divScheduleLession").fadeOut();
                $("#divDayOff").fadeIn()();
                $("#notificationText1").fadeOut();
                $("#notificationText1").empty();
                $("#getSubjectID").empty();
            } else {
                $("#divScheduleSubject").fadeIn();
                $("#divScheduleLession").fadeIn();
                $("#divDayOff").fadeOut();
                $("#notificationText1").fadeOut();
                $("#notificationText1").empty();
                $("#getSubjectID").empty();
            }
        });
    }


    if ($("#inputScheduleSubject").length > 0) {
        $("#inputScheduleSubject").change(function() {
//alert("Current value:" + $(this).val());

            if ($("#inputScheduleDateSubject").val().length <= 0) {
                alert("Please select beginning date");
                $("#inputScheduleDateSubject").focus();
                return false;
            }
            $.ajax({
                type: 'GET',
                url: "../Lession/getlist/" + $(this).val(),
                dataType: 'json',
                contentType: 'application/json',
                success: function(data) {
                    $(":input#inputNumberOfLession").val(data.length);
                    var rooms = $("#rooms");
                    rooms.empty();
                    var d_get = new Date($('#inputScheduleDateSubject').datepicker('getDate'));
                    if (data.length > 0) {
                        //alert(d_get.getDay() + 1);
                        if ($(".sltDayOfWeek").length > 0) {

//                            var arrSltDayOfWeek = [];
//                            $(".sltDayOfWeek:checked").each(function() {
//                                arrSltDayOfWeek.push(parseInt(this.value));
//                            });
//                            //alert(arrSltDayOfWeek);
//                            var totalLession = data.length;
//                            var currentLession = 0;
//                            if (arrSltDayOfWeek.length == 0) {
//                                $("div#sltDay").css("border", "red 1px solid");
//                                alert("Select day of week");
//                                return false;
//                            } else {
//                                $("div#sltDay").removeAttr("style");
//                            }
//                            while (currentLession < totalLession) {
//                                var dayOfWeek = d_get.getDay() + 1;
//                                if (arrSltDayOfWeek.indexOf(dayOfWeek) == -1) {
//                                    d_get.setDate(d_get.getDate() + 1);
//                                } else {
//                                    rooms.append("<div class='control-group'><label class='control-label' for='inputScheduleLession" + (currentLession + 1) + "'>Lession " + (currentLession + 1) + ": </label><div class='controls'><input type='text' id='inputScheduleLession" + (currentLession + 1) + "' class='inputScheduleDateSubject' name='inputScheduleLession" + (currentLession + 1) + "' value='" + ('0' + d_get.getDate()).slice(-2) + "/" + ('0' + (d_get.getMonth() + 1)).slice(-2) + "/" + d_get.getFullYear() + "'/><select id='lstLession" + (currentLession + 1) + "' name='lstLession" + (currentLession + 1) + "'></select></div></div>");
//                                    d_get.setDate(d_get.getDate() + 1);
//                                    currentLession++;
//                                }
//                            }
//                            for (i = 1; i < totalLession + 1; i++) {
//                                var sltListBox = $("#lstLession" + i);
//                                for (j = 0; j < totalLession; j++) {
//                                    var opSlt = "";
//                                    if (i == (j + 1)) {
//                                        opSlt = " selected='selected' ";
//                                    }
//                                    sltListBox.append("<option value='" + data[j].lession_id + "' " + opSlt + ">" + data[j].lession_name + "</option>");
//                                }
//                            }

                            var lstLession = $("#listLession");
                            lstLession.empty();
                            lstLession.append("<option value='-1'>*</option>");
                            for (var i = 0; i < data.length; i++) {
                                lstLession.append("<option value='" + data[i].lession_id + "'>" + data[i].lession_name + "</option>");
                            }
                        } else {
                            var lstLession = $("#inputScheduleLession");
                            lstLession.empty();
                            lstLession.append("<option value='-1'>-------</option>")
                            for (var i = 0; i < data.length; i++) {
                                lstLession.append("<option value='" + data[i].lession_id + "'>" + data[i].lession_name + "</option>");
                            }
                        }
                        $(".inputScheduleDateSubject").datepicker({
                            dateFormat: 'dd/mm/yy',
                        });
                    } else {
                        rooms.append("Empty lession");
                    }

                }
            });
        });
    }
    //kiểm tra người dùng chon "*" thì list lession được select all
    $("#listLession").on('click',"option" ,function() {
        
        
        if ($(this).val() == -1) {
            // sử dụng .prop để có thể kick lại nhiều lần
             $("#listLession").find("option").prop("selected", false);
             $("#listLession").find("option").prop("selected", true);
            $("#listLession option:first").prop('selected', false);
        }
    });

//button "Đặt chỗ" for update
    if ($("#btnPutSchedule").length > 0) {
        var lstLession = $("#listLession");

        $("#btnPutSchedule").on("click", function() {
            if ($("#listLession :selected").size() <= 0) {
                //kiểm tra nếu không có cái nào được lựa chọn thì thông báo
                alert("Please select lession to schedule");
            } else {

                //lấy ra các thứ trong tuần
                var arrSltDayOfWeek = [];
                $(".sltDayOfWeek:checked").each(function() {
                    arrSltDayOfWeek.push(parseInt(this.value));
                });
                //lấy ra các môn học đã lựa chọn trong list trên
                var arrSltLessionName = [];
                var arrSltLessionID = [];
                var totalLession = 0;//tổng số lession
                var currentLession = 0; // bắt lession hiện tại
                $("#listLession :selected").each(function(i, selected) {
                    arrSltLessionName[i] = $(selected).text();
                    arrSltLessionID[i] = $(selected).val();
                    totalLession++;
                });
                //đặt lịch các ngày đã chọn
                var rooms = $("#rooms");//div chứa ngoài các ngày sẽ được đặt
                rooms.empty();
                var d_get = new Date($('#inputScheduleDateSubject').datepicker('getDate'));
                while (currentLession < totalLession) {
                    var dayOfWeek = d_get.getDay() + 1;
                    if (arrSltDayOfWeek.indexOf(dayOfWeek) == -1) {
                        d_get.setDate(d_get.getDate() + 1);
                    } else {
                        rooms.append("<div class='control-group' id='divScheduleLession" + (currentLession + 1) + "'><label class='control-label' for='inputScheduleLession" + (currentLession + 1) + "'>Lession " + (currentLession + 1) + ": </label><div class='controls'><input type='text' id='inputScheduleLession" + (currentLession + 1) + "' class='inputScheduleDateSubject' name='inputScheduleLession" + (currentLession + 1) + "' value='" + ('0' + d_get.getDate()).slice(-2) + "/" + ('0' + (d_get.getMonth() + 1)).slice(-2) + "/" + d_get.getFullYear() + "'/><select id='lstLession" + (currentLession + 1) + "' name='lstLession" + (currentLession + 1) + "'></select><a href='#' onclick = \"ConfirmChoiceRemoveLession('divScheduleLession" + (currentLession + 1) + "'); return false;\"><img src='../media/img/dash_remove_icon.png' /></a></div></div>");
                        d_get.setDate(d_get.getDate() + 1);
                        currentLession++;
                    }
                }
                for (i = 1; i < totalLession + 1; i++) {
                    var sltListBox = $("#lstLession" + i);
                    for (j = 0; j < totalLession; j++) {
                        var opSlt = "";
                        if (i == (j + 1)) {
                            opSlt = " selected='selected' ";
                        }
                        sltListBox.append("<option value='" + arrSltLessionID[j] + "' " + opSlt + ">" + arrSltLessionName[j] + "</option>");
                    }
                }
                $(".inputScheduleDateSubject").datepicker({
                    dateFormat: 'dd/mm/yy',
                });
            }
        })

    }

//get schedule from date to date
    if ($("#btnGetListSchedule").length > 0) {
        $("#btnGetListSchedule").click(function() {
            var cls = $('#inputScheduleClassBySch').val();
            var fromDate = $("#inputBeginDate").val();
            var toDate = $("#inputEndDate").val();

//            if (fromDate.length <= 0 ||
//                    toDate.length <= 0) {
//
//                if ($("#inputBeginDate").val().length <= 0) {
//                    $("#inputBeginDate").focus();
//                    return false;
//                } else if ($("#inputEndDate").val().length <= 0) {
//                    $("#inputEndDate").focus();
//                    return false;
//                }
//
//
//            }
            if (cls == -1)
                cls = "";
            if (fromDate.length <= 0)
                fromDate = '';
            if (toDate.length <= 0)
                toDate = '';

            var fromDate = fromDate.replace(/\//g, "");
            var toDate = toDate.replace(/\//g, "");
            //alert("../schedule/getdatetodate/");
            $.ajax({
                type: 'GET',
                url: "../schedule/getdatetodate/" + fromDate + "to" + toDate + "cls" + cls,
                data: 'json',
                contentType: 'application/json',
                success: function(data) {
                    var tblList = $("#tblSchedule tbody");
                    tblList.empty();
                    //alert(data.length);
                    if (data.length > 0) {
                        for (var i = 0; i < data.length; i++) {
                            var strLss = data[i].lession_name;
                            if (strLss.indexOf("#@@#@#@#@#") != -1) {
                                //alert(strLss);
                                data[i].lession_name = strLss.split("#@@#@#@#@#")[1];
                            }
                            tblList.append("<tr><td><input name='id[]' type='checkbox' id='checkboxId[]' value='" + data[i].schedule_id + "'></td><td>" + data[i].classname + "</td><td>" + data[i].dates.split("-")[2] + "-" + data[i].dates.split("-")[1] + "-" + data[i].dates.split("-")[0] + "</td><td>" + data[i].lession_name + "</td><td>" + data[i].theory + "</td><td>" + data[i].lab + "</td><td><a class = 'btn' href = '../schedule/update/" + data[i].schedule_id + "' > <i class = 'icon-edit' > </i></a><a class = 'btn btn-danger' href = '#' onclick = \"ConfirmChoiceDelete('../schedule/delete/" + data[i].schedule_id + "');return false; \"><i class='icon-remove-sign'></i></a></td></tr>");
                        }
                    } else {
                        tblList.append("<tr><td colspan='7'>No lession</td></tr>");
                    }
                    $("#smart-paginator").empty();
                    var rowCount = $('#tblSchedule tbody tr').length;
                    paginationSchedule(rowCount, 'tblSchedule');
                }
            });
        });
    }

    $('#inputNewsCategoriesBySch').change(function() {
        
        var CategoryID = $(this).val();
        
        //du lieu goi di, co bien category_id 
        data = {'category_id': CategoryID};
        // ham post của jQuery - co cach dung:
        //$.post('duogn dan lay du lieu', 'du lieu goi di de lay', 'ham nhan ket qua', 'loai ket qua');
        $.post('../news/search', data, function(result) {
            a = result.data;
            
            //nhan ket qua tra ve cua url qua bien result

            //dataAppend la html minh tao trong js
            var dataAppend = '';
            // truong hop co loi tra ve ben controller; 

            if (result === null || typeof (result.error) == 'undefind' || result.data.length == 0) {
                //tao col 7 cot
                dataAppend = '<tr><td colspan="7">Không có dữ liệu</td></tr>';
            } else {
                //truong hop chay ko loi
                // va co du lieu tra ve;
                //bat dau duyet qua, ket qua result
                $.each(result.data, function(ind, record) {
                    //alert(ind);
                    dataAppend += '<tr><td><input name="news_id[]" type="checkbox" news_id="checkboxnews_id[]" value="' + record['news_id'] + '" /></td>' +
                            '<td>' + record['news_id'] + '</td>' +
                            '<td>' + record['title'] + '</td>' +
                            '<td>' + record['category_name'] + '</td>' +
                            '<td>' + ((record['status'] == 1) ? "Active" : "Deacive") + '</td>' +
                            '<td>' + record['content'] + '</td>' +
                            '<td><div class="btn-group">' +
                            '<a class="btn" href="../News/Update/' + record['news_id'] + '"><i class="icon-edit"></i></a>' +
                            '<a class="btn" href="../News/Delete/' + record['news_id'] + '"><i class="icon-remove-sign"></i></a>' +
                            '</div></td>' +
                            '</tr>';
                });
            }

            // bat dau noi chuoi html vao vi tri minh can hien thi;
            $('#news-search').html(dataAppend);
            $("#smart-paginator").empty();
            paginationSchedule(result.data.length, 'tablePagination');
        }, 'json');
        
            
    })

    /*            $.ajax({
     type: 'GET',
     url: "../news"  + "ctg" + ctg,
     data: 'json',
     contentType: 'application/json',
     success: function(data) {
     var tblList = $("#tblNews tbody");
     tblList.empty();
     //alert(data.length);
     if (data.length > 0) {
     for (i = 0; i < data.length; i++) {
     tblList.append("<tr><td><input name='id[]' type='checkbox' id='checkboxId[]' value='" + data[i].news_id + "'></td><td>" + data[i].title + "</td><td>" + "</td><td>" + data[i].category_name + "</td><td>" + data[i].status + "</td><td>" + data[i].content + "</td><td><a class = 'btn' href = '../news/update/" + data[i].news_id + "' > <i class = 'icon-edit' > </i></a><a class = 'btn btn-danger' href = '#' onclick = \"ConfirmChoiceDelete('../news/delete/" + data[i].news_id + "');return false; \"><i class='icon-remove-sign'></i></a></td></tr>");
     }
     } else {
     tblList.append("<tr><td colspan='7'>No lession</td></tr>");
     }
     }
     });
     });
     }
     */
    /*    if ($("#btnGetListNews").length > 0) {
     $("#btnGetListNews").click(function() {
     var courses = $('#inputSubjectCourseBySch').val();
     
     $.ajax({
     type: 'GET',
     url: "../course"  + "courses" + courses,
     data: 'json',
     contentType: 'application/json',
     success: function(data) {
     var tblList = $("#tblSubject tbody");
     tblList.empty();
     //alert(data.length);
     if (data.length > 0) {
     for (i = 0; i < data.length; i++) {
     tblList.append("<tr><td><input name='id[]' type='checkbox' id='checkboxId[]' value='" + data[i].subject_id + "'></td><td>" + data[i].title + "</td><td>" + "</td><td>" + data[i].courses_name + "</td><td>" + data[i].status + "</td><td>" + data[i].content + "</td><td><a class = 'btn' href = '../news/update/" + data[i].subject_id + "' > <i class = 'icon-edit' > </i></a><a class = 'btn btn-danger' href = '#' onclick = \"ConfirmChoiceDelete('../news/delete/" + data[i].subject_id + "');return false; \"><i class='icon-remove-sign'></i></a></td></tr>");
     }
     } else {
     tblList.append("<tr><td colspan='7'>No lession</td></tr>");
     }
     }
     });
     });
     }
     });*/


//    $('#inputSubjectCourseBySch').change(function() {
//        var CourseId = $(this).val(); // this la cai inputSubjectCourseBySch thay doi;
//        data = {'course_id': CourseId}; // day la dk de lay thong tin;
//        //'/subject/search/' la controller action de lay thong tin
//        $.post('../subject/search/', data, function(result) {
//            
//            var dataAppend = '';
//            if (typeof (result.error) == 'undefine') {
//                dataAppend = '<tr><td>ko co du lieu</td></tr>';
//            } else {
//                $.each(result, function(ind, record) {
//                    dataAppend += '<tr><td><input name="subject_id[]" type="checkbox" subject_id="checkboxsubject_id[]" value="' + record['subject_id'] + '"></td>' +
//                            '<td>' + record['subject_id'] + '</td>' +
//                            '<td>' + record['subject_name'] + '</td>' +
//                            '<td>' + record['courses_name'] + '</td>' +
//                            '<td>' + ((record['status'] == 1) ? "Active" : "Deactive") + '</td>' +
//                            '<td>' + record['keyword'] + '</td>' +
//                            '<td>' + record['description'] + '</td>' +
//                            '<td> <div class="btn-group">'+
//                                    '<a class="btn" href="../subject/update/' + record['subject_id'] + '"><i class="icon-edit"></i></a>'+
//                                    '<a class="btn" href="#" onclick="ConfirmChoiceDelete(\'../subject/update/'+ record['subject_id']+'\');'+
//                                    'return false;"><i class="icon-remove-sign"></i></a>'+
//                                '</div></td>' +
//                            '</tr>';
//                });
//            }
//            $('#subject-search').html(dataAppend);
//        }, 'json');
//    })
    $("#btnCrateSchedule").on("click", function() {
        if ($("#rooms").find(".control-group").length <= 0) {
            alert("Please schdedule before click submit");
            return false;
        }
    });
    $('#inputSubjectCourseBySch').change(function() {
        var courseID = $(this).val();
        $("#subject-search").empty();
        $.ajax({
            type: 'POST',
            data: 'course_id=' + courseID,
            url: '../subject/search/',
            dataType: 'json',
            success: function(record) {
                if (record.length == 0) {
                    $("#subject-search").append('<tr><td colspan="7">Empty</td></tr>');
                } else {
                    for (var i = 0; i < record.length; i++) {
                        var dataAppend = '<tr><td><input name="subject_id[]" type="checkbox" subject_id="checkboxsubject_id[]" value="' + record[i].subject_id + '"></td>' +
                                '<td>' + record[i].subject_id + '</td>' +
                                '<td>' + record[i].subject_name + '</td>' +
                                '<td>' + record[i].courses_name + '</td>' +
                                '<td>' + ((record[i].status == 1) ? "Active" : "Deactive") + '</td>' +
                                '<td>' + record[i].keyword + '</td>' +
                                '<td>' + record[i].description + '</td>' +
                                '<td> <div class="btn-group">' +
                                '<a class="btn" href="../subject/update/' + record[i].subject_id + '"><i class="icon-edit"></i></a>' +
                                '<a class="btn" href="#" onclick="ConfirmChoiceDelete(\'../subject/update/' + record[i].subject_id + '\');' +
                                'return false;"><i class="icon-remove-sign"></i></a>' +
                                '</div></td>' +
                                '</tr>';
                        $("#subject-search").append(dataAppend);
                    }
                }
                $("#smart-paginator").empty();
                var rowCount = $('#tablePagination tbody tr').length;
                paginationSchedule(rowCount, 'tablePagination');
            }


        });

    });


//    $('textarea#inputBody').ckeditorGet().on('key', function(e) {
//        var strBodyText = $('textarea#inputBody').text().replace(/(<([^>]+)>)/ig, "");
//        $("textarea#inputContent").detach();
//        $("div#forInputContent").append('<textarea id="inputContent" class="editor_noimage" name="content" placeholder="Content" style="margin: 0px; height: 167px; width: 457px;"></textarea>')
//        $("textarea#inputContent").append(strBodyText.substring(0, strBodyText.indexOf(" ", 200)) + "...");
//
//    });
})
function ConfirmChoiceRemoveLession(idRemove)
{
    // alert(idRemove);
    answer = confirm("Do you really want to remove this lession?")
    if (answer != 0)
    {
        $("#" + idRemove).fadeOut('slow', function() {
            $(this).remove();
        });
        // $("#"+idRemove).remove();
    }

}
// confirm when client delete an item
function ConfirmChoiceDelete(url)
{
    answer = confirm("Do you really want to delete it?")
    if (answer != 0)
    {
        location = url
    }
}

function paginationSchedule(pageNumber, table) {
    //var rowCount = $('#tblSchedule tbody tr').length;
    //alert(rowCount);

    $('#smart-paginator').smartpaginator({
        totalrecords: pageNumber,
        recordsperpage: 20,
        controlsalways: false,
        datacontainer: table,
        dataelement: "tr",
        length: 5,
        initval: 0,
        next: 'Next',
        prev: 'Prev',
        first: 'First',
        last: 'Last',
        display: 'double',
        theme: 'none',
        onchange: returnTrue
    });
}
function returnTrue() {
    $("html, body").animate({scrollTop: 0}, "slow");
    $('html, body').stop(true, true);
    return false;
}
// confirm when client delete multi item
function ConfirmChoiceDeleteMulti()
{
    answer = confirm("Do you really want to delete it?")
    if (answer != 0)
    {
        return true;
    } else {
        return false;
    }
} 